package com.jm.offer.easy;

/**
 * @Description https://leetcode-cn.com/problems/bu-yong-jia-jian-cheng-chu-zuo-jia-fa-lcof/
 * @date 2022/5/5 14:39
 */
public class _65不用加减乘除做加法 {
    public static void main(String[] args) {

    }
    public static int add(int a, int b) {
        // sum记录为进位的和 tmp记录进位
        int sum, tmp;
        do{
            sum = a ^ b;
            tmp = (a & b) << 1;
            a = sum;
            b = tmp;
        }while(tmp != 0);
        return sum;
    }
}
